package com.example.interview.Thread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class CallableExample {
    public static void main(String[] args) throws Exception {
        Callable<Integer> callable = new Callable<Integer>() {
            public Integer call() {
                // 线程的主体逻辑
                return 123;
            }
        };

        FutureTask<Integer> futureTask = new FutureTask<>(callable);
        Thread thread = new Thread(futureTask);
        thread.start();

        int result = futureTask.get(); // 获取线程返回的结果
        System.out.println("Result: " + result);
    }
}
